package com.demo.service;

import cn.hutool.core.util.RandomUtil;
import cn.lingyangwl.framework.data.mate.annotations.FieldBindHandle;
import com.demo.entity.BigDataPO;
import com.github.yitter.idgen.YitIdHelper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shenguangyang
 */
@Service
public class FieldBindTestService {

    @FieldBindHandle
    public List<BigDataPO> listBigDataPo() {
        List<BigDataPO> bigDataPOS = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            bigDataPOS.add(getBigDataPO());
        }
        return bigDataPOS;
    }

    @FieldBindHandle
    public BigDataPO getBigDataPO() {
        BigDataPO bigDataPO = new BigDataPO();
        bigDataPO.setId(String.valueOf(YitIdHelper.nextId()));
        bigDataPO.setCreateTime(System.currentTimeMillis());
        bigDataPO.setAvatarUrl(RandomUtil.randomString(100));
        bigDataPO.setUsername(RandomUtil.randomString(100));
        bigDataPO.setPassword(RandomUtil.randomString(100));
        bigDataPO.setNickname(RandomUtil.randomString(16));
        bigDataPO.setHomeAddress(RandomUtil.randomString(100));
        bigDataPO.setEmail(RandomUtil.randomString(24));
        bigDataPO.setPhone(RandomUtil.randomNumbers(13));
        bigDataPO.setIdCode(RandomUtil.randomNumbers(16));
        bigDataPO.setDeleteFlag(RandomUtil.randomInt(1, 2));
        bigDataPO.setSex(RandomUtil.randomInt(1, 100) > 50 ? 1 : 2);
        bigDataPO.setStatus(String.valueOf(RandomUtil.randomInt(1, 5)));
        bigDataPO.setLastLogin(System.currentTimeMillis());
        bigDataPO.setUpdateTime(System.currentTimeMillis());
        bigDataPO.setUserId(String.valueOf(RandomUtil.randomLong(1, 10000)));
        return bigDataPO;
    }
}
